package SelectLessonUI;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.rmi.RemoteException;

import javax.swing.JPanel;

import LessonBL.LessonLogicService;
import LessonUI.LessonDetail;
import RMI.RMIHelper;

public class TeacherViewSelectLesson extends JPanel
{
	SelectLessonSelect sls;
	LessonDetail ld;
	
	public TeacherViewSelectLesson()
	{
		super();
		setSize(1280,725*4/5);
		setVisible(true);
		setLayout(null);
		setOpaque(false);
		sls = new SelectLessonSelect();
		ld = new LessonDetail();
		
		this.add(sls);
		sls.setBounds(0, 0,512,580);
		sls.setVisible(true);
		
		this.add(ld);
		ld.setBounds(512,0,700,580);
		ld.setVisible(true);

		setSelectLessonSelect();
		setLessonDetail();
		repaint();
	}
	public void setSelectLessonSelect()
	{
		sls.studentID.setEditable(false);
		sls.table.addMouseListener(new tableListener());
	}
	
	public void setLessonDetail()
	{
		
		ld.setUnchange();
	}
	
	public class tableListener implements MouseListener
	{
		public void mouseClicked(MouseEvent arg0)
		{
			int number = sls.table.getSelectedRow();
			String lesson = sls.list.get(number).lesson;
			RMIHelper rmi = new RMIHelper();
			LessonLogicService lls = rmi.getLessonService();
			try
			{
				ld.showLesson(lls.getLesson(lesson));
			} catch (RemoteException e)
			{
				e.printStackTrace();
			}
		}

		public void mouseEntered(MouseEvent arg0)
		{
		}

		public void mouseExited(MouseEvent arg0)
		{
		}

		public void mousePressed(MouseEvent arg0)
		{
		}

		public void mouseReleased(MouseEvent arg0)
		{
		}
	}
}
